//#include "interface.h"
#ifndef PTLOCK_H
#define PTLOCK_H

//#define atomic_add_1(_addr_) \
{         unsigned long _new_;\
          asm volatile("faaw   %0,0(%1)\n\t"  \
               :"=r"(_new_):"r"(_addr_):"memory");        \
}

#define NT 64

int size;
extern volatile unsigned long head  ;
extern volatile unsigned long tail ;
extern volatile unsigned long waitq[NT]  ;
volatile int destq[NT] ;

void init_ptlock();
int slave_get_msg_from_RegN();
void send_msg_to_id(long destid, int value);
//void slave_init_ptlock(PTLock* lock);
unsigned long slave_get_ticket(unsigned long* head);
//void slave_wait( unsigned long ticket);
void slave_lock();
void slave_unlock();
#endif
